<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="主键" prop="uId">-->
<!--        <el-input-->
<!--          v-model="queryParams.uId"-->
<!--          placeholder="请输入主键"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="一级分类" prop="cpcc">
        <el-input
          v-model="queryParams.cpcc"
          placeholder="请输入一级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="二级分类" prop="cpmc">
        <el-input
          v-model="queryParams.cpmc"
          placeholder="请输入二级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="三级分类" prop="cpxf">
        <el-input
          v-model="queryParams.cpxf"
          placeholder="请输入三级分类"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业名称" prop="gsmc">
        <el-input
          v-model="queryParams.gsmc"
          placeholder="请输入企业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="统一代码" prop="tydm">
        <el-input
          v-model="queryParams.tydm"
          placeholder="请输入统一代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="法人" prop="fzr">
        <el-input
          v-model="queryParams.fzr"
          placeholder="请输入法人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="注册资本" prop="zczb">
        <el-input
          v-model="queryParams.zczb"
          placeholder="请输入注册资本"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业类型" prop="gslx">
        <el-input
          v-model="queryParams.gslx"
          placeholder="请输入企业类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="经营状态" prop="jyzt">
        <el-input
          v-model="queryParams.jyzt"
          placeholder="请输入经营状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产业类型" prop="lx">
        <el-input
          v-model="queryParams.lx"
          placeholder="请输入产业类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否进出口" prop="isJck">
        <el-input
          v-model="queryParams.isJck"
          placeholder="请输入是否进出口"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否社保人数超百人" prop="isSbbr">
        <el-input
          v-model="queryParams.isSbbr"
          placeholder="请输入是否社保人数超百人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否社保人数超二十人" prop="isSbes">
        <el-input
          v-model="queryParams.isSbes"
          placeholder="请输入是否社保人数超二十人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否年营收超百万" prop="isYsbw">
        <el-input
          v-model="queryParams.isYsbw"
          placeholder="请输入是否年营收超百万"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否近期有融资" prop="isRz">
        <el-input
          v-model="queryParams.isRz"
          placeholder="请输入是否近期有融资"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否注册金额超百万" prop="isZcbw">
        <el-input
          v-model="queryParams.isZcbw"
          placeholder="请输入是否注册金额超百万"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="区域" prop="qy">
        <el-input
          v-model="queryParams.qy"
          placeholder="请输入区域"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="认缴注册资本(万元)" prop="rjzczb">
        <el-input
          v-model="queryParams.rjzczb"
          placeholder="请输入认缴注册资本(万元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="2023年1-3月进出口总额(美元)" prop="jck">
        <el-input
          v-model="queryParams.jck"
          placeholder="请输入2023年1-3月进出口总额(美元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="2023年4月末社保缴纳人数(人)" prop="sbrs">
        <el-input
          v-model="queryParams.sbrs"
          placeholder="请输入2023年4月末社保缴纳人数(人)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="2022年营业收人(元)" prop="yysr">
        <el-input
          v-model="queryParams.yysr"
          placeholder="请输入2022年营业收人(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="2023年4月新发放贷款金额(元)" prop="dkje">
        <el-input
          v-model="queryParams.dkje"
          placeholder="请输入2023年4月新发放贷款金额(元)"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="授权ID" prop="companyId">
        <el-input
          v-model="queryParams.companyId"
          placeholder="请输入授权ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业简称" prop="shortName">
        <el-input
          v-model="queryParams.shortName"
          placeholder="请输入企业简称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成立时间" prop="esdate">
        <el-input
          v-model="queryParams.esdate"
          placeholder="请输入成立时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['bigscreen:dnBase:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['bigscreen:dnBase:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['bigscreen:dnBase:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['bigscreen:dnBase:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="dnBaseList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="主键" align="center" prop="uId" />
      <el-table-column label="一级分类" align="center" prop="cpcc" />
      <el-table-column label="二级分类" align="center" prop="cpmc" />
      <el-table-column label="三级分类" align="center" prop="cpxf" />
      <el-table-column label="企业名称" align="center" prop="gsmc" />
      <el-table-column label="统一代码" align="center" prop="tydm" />
      <el-table-column label="法人" align="center" prop="fzr" />
      <el-table-column label="注册资本" align="center" prop="zczb" />
      <el-table-column label="企业类型" align="center" prop="gslx" />
      <el-table-column label="经营状态" align="center" prop="jyzt" />
      <el-table-column label="产业类型" align="center" prop="lx" />
      <el-table-column label="是否进出口" align="center" prop="isJck" />
      <el-table-column label="是否社保人数超百人" align="center" prop="isSbbr" />
      <el-table-column label="是否社保人数超二十人" align="center" prop="isSbes" />
      <el-table-column label="是否年营收超百万" align="center" prop="isYsbw" />
      <el-table-column label="是否近期有融资" align="center" prop="isRz" />
      <el-table-column label="是否注册金额超百万" align="center" prop="isZcbw" />
      <el-table-column label="区域" align="center" prop="qy" />
      <el-table-column label="认缴注册资本(万元)" align="center" prop="rjzczb" />
      <el-table-column label="2023年1-3月进出口总额(美元)" align="center" prop="jck" />
      <el-table-column label="2023年4月末社保缴纳人数(人)" align="center" prop="sbrs" />
      <el-table-column label="2022年营业收人(元)" align="center" prop="yysr" />
      <el-table-column label="2023年4月新发放贷款金额(元)" align="center" prop="dkje" />
      <el-table-column label="授权ID" align="center" prop="companyId" />
      <el-table-column label="企业简称" align="center" prop="shortName" />
      <el-table-column label="成立时间" align="center" prop="esdate" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['bigscreen:dnBase:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['bigscreen:dnBase:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改产业大脑_基础信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<!--        <el-form-item label="主键" prop="uId">-->
<!--          <el-input v-model="form.uId" placeholder="请输入主键" />-->
<!--        </el-form-item>-->
        <el-form-item label="一级分类" prop="cpcc">
          <el-input v-model="form.cpcc" placeholder="请输入一级分类" />
        </el-form-item>
        <el-form-item label="二级分类" prop="cpmc">
          <el-input v-model="form.cpmc" placeholder="请输入二级分类" />
        </el-form-item>
        <el-form-item label="三级分类" prop="cpxf">
          <el-input v-model="form.cpxf" placeholder="请输入三级分类" />
        </el-form-item>
        <el-form-item label="企业名称" prop="gsmc">
          <el-input v-model="form.gsmc" placeholder="请输入企业名称" />
        </el-form-item>
        <el-form-item label="统一代码" prop="tydm">
          <el-input v-model="form.tydm" placeholder="请输入统一代码" />
        </el-form-item>
        <el-form-item label="法人" prop="fzr">
          <el-input v-model="form.fzr" placeholder="请输入法人" />
        </el-form-item>
        <el-form-item label="注册资本" prop="zczb">
          <el-input v-model="form.zczb" placeholder="请输入注册资本" />
        </el-form-item>
        <el-form-item label="企业类型" prop="gslx">
          <el-input v-model="form.gslx" placeholder="请输入企业类型" />
        </el-form-item>
        <el-form-item label="经营状态" prop="jyzt">
          <el-input v-model="form.jyzt" placeholder="请输入经营状态" />
        </el-form-item>
        <el-form-item label="产业类型" prop="lx">
          <el-input v-model="form.lx" placeholder="请输入产业类型" />
        </el-form-item>
        <el-form-item label="是否进出口" prop="isJck">
          <el-input v-model="form.isJck" placeholder="请输入是否进出口" />
        </el-form-item>
        <el-form-item label="是否社保人数超百人" prop="isSbbr">
          <el-input v-model="form.isSbbr" placeholder="请输入是否社保人数超百人" />
        </el-form-item>
        <el-form-item label="是否社保人数超二十人" prop="isSbes">
          <el-input v-model="form.isSbes" placeholder="请输入是否社保人数超二十人" />
        </el-form-item>
        <el-form-item label="是否年营收超百万" prop="isYsbw">
          <el-input v-model="form.isYsbw" placeholder="请输入是否年营收超百万" />
        </el-form-item>
        <el-form-item label="是否近期有融资" prop="isRz">
          <el-input v-model="form.isRz" placeholder="请输入是否近期有融资" />
        </el-form-item>
        <el-form-item label="是否注册金额超百万" prop="isZcbw">
          <el-input v-model="form.isZcbw" placeholder="请输入是否注册金额超百万" />
        </el-form-item>
        <el-form-item label="区域" prop="qy">
          <el-input v-model="form.qy" placeholder="请输入区域" />
        </el-form-item>
        <el-form-item label="认缴注册资本(万元)" prop="rjzczb">
          <el-input v-model="form.rjzczb" placeholder="请输入认缴注册资本(万元)" />
        </el-form-item>
        <el-form-item label="2023年1-3月进出口总额(美元)" prop="jck">
          <el-input v-model="form.jck" placeholder="请输入2023年1-3月进出口总额(美元)" />
        </el-form-item>
        <el-form-item label="2023年4月末社保缴纳人数(人)" prop="sbrs">
          <el-input v-model="form.sbrs" placeholder="请输入2023年4月末社保缴纳人数(人)" />
        </el-form-item>
        <el-form-item label="2022年营业收人(元)" prop="yysr">
          <el-input v-model="form.yysr" placeholder="请输入2022年营业收人(元)" />
        </el-form-item>
        <el-form-item label="2023年4月新发放贷款金额(元)" prop="dkje">
          <el-input v-model="form.dkje" placeholder="请输入2023年4月新发放贷款金额(元)" />
        </el-form-item>
        <el-form-item label="授权ID" prop="companyId">
          <el-input v-model="form.companyId" placeholder="请输入授权ID" />
        </el-form-item>
        <el-form-item label="企业简称" prop="shortName">
          <el-input v-model="form.shortName" placeholder="请输入企业简称" />
        </el-form-item>
        <el-form-item label="成立时间" prop="esdate">
          <el-input v-model="form.esdate" placeholder="请输入成立时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listDnBase, getDnBase, delDnBase, addDnBase, updateDnBase } from "@/api/industry/dnBase";

export default {
  name: "DnBase",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产业大脑_基础信息表格数据
      dnBaseList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        uId: null,
        cpcc: null,
        cpmc: null,
        cpxf: null,
        gsmc: null,
        tydm: null,
        fzr: null,
        zczb: null,
        gslx: null,
        jyzt: null,
        lx: null,
        isJck: null,
        isSbbr: null,
        isSbes: null,
        isYsbw: null,
        isRz: null,
        isZcbw: null,
        qy: null,
        rjzczb: null,
        jck: null,
        sbrs: null,
        yysr: null,
        dkje: null,
        companyId: null,
        shortName: null,
        esdate: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询产业大脑_基础信息列表 */
    getList() {
      this.loading = true;
      listDnBase(this.queryParams).then(response => {
        this.dnBaseList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        uId: null,
        cpcc: null,
        cpmc: null,
        cpxf: null,
        gsmc: null,
        tydm: null,
        fzr: null,
        zczb: null,
        gslx: null,
        jyzt: null,
        lx: null,
        isJck: null,
        isSbbr: null,
        isSbes: null,
        isYsbw: null,
        isRz: null,
        isZcbw: null,
        qy: null,
        rjzczb: null,
        jck: null,
        sbrs: null,
        yysr: null,
        dkje: null,
        companyId: null,
        shortName: null,
        esdate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.uId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加产业大脑_基础信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const uId = row.uId || this.ids
      getDnBase(uId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改产业大脑_基础信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.uId != null) {
            updateDnBase(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDnBase(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const uIds = row.uId || this.ids;
      this.$modal.confirm('是否确认删除产业大脑_基础信息编号为"' + uIds + '"的数据项？').then(function() {
        return delDnBase(uIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('bigscreen/dnBase/export', {
        ...this.queryParams
      }, `dnBase_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
